home *** CD-ROM | disk | FTP | other *** search
/ Champak 141 / (Vol 141) Oct 17 2011.iso / Games / gamma-bros.swf / scripts / __Packages / classes / shots / DroidCMissle.as < prev    next >
Encoding:
Text File  |  2011-10-17  |  6.1 KB  |  210 lines

  1. class classes.shots.DroidCMissle
  2. {
  3.    var x;
  4.    var y;
  5.    var id;
  6.    var dir;
  7.    var clip;
  8.    var axis;
  9.    var speed;
  10.    var ac;
  11.    var ep;
  12.    var xMov = 0;
  13.    var yMov = 0;
  14.    var xMovT = 0;
  15.    var yMovT = 0;
  16.    var Name = "droidCMissle";
  17.    var power = 25;
  18.    var yank = false;
  19.    function DroidCMissle(px, py, pdir, pid)
  20.    {
  21.       this.x = px;
  22.       this.y = py;
  23.       this.id = pid;
  24.       this.dir = pdir;
  25.       _root.d = _root.d + 1;
  26.       this.clip = _root.attachMovie("droidCMissle","droidCMissle" + this.id + "Clip",_root.d);
  27.       this.clip._x = this.x;
  28.       this.clip._y = this.y;
  29.       this.clip.id = this.id;
  30.       this.xMov = 0;
  31.       this.yMov = 0;
  32.       if(this.dir == "U")
  33.       {
  34.          this.axis = "y";
  35.          this.yMovT = -8;
  36.          this.xMovT = 0;
  37.       }
  38.       else if(this.dir == "D")
  39.       {
  40.          this.axis = "y";
  41.          this.yMovT = 8;
  42.          this.xMovT = 0;
  43.       }
  44.       else if(this.dir == "R")
  45.       {
  46.          this.axis = "x";
  47.          this.yMovT = 0;
  48.          this.xMovT = 8;
  49.       }
  50.       else
  51.       {
  52.          this.axis = "x";
  53.          this.yMovT = 0;
  54.          this.xMovT = -8;
  55.       }
  56.       this.speed = 8;
  57.       this.xMov *= _root.dif.speed;
  58.       this.yMov *= _root.dif.speed;
  59.       this.speed *= _root.dif.speed;
  60.       this.clip.gotoAndStop("fly" + this.dir);
  61.       this.xMovT *= _root.randRange2(0.9,1.1);
  62.       this.yMovT *= _root.randRange2(0.9,1.1);
  63.       this.ac = 0;
  64.       this.ep = _root.randRange(10,30);
  65.    }
  66.    function hit()
  67.    {
  68.       _root.createExploA([this.x + this.clip._width / 2,this.y + this.clip._height / 2,_root.randRange(60,80),_root.randRange(85,100),"Purple"]);
  69.       _root.audio.playLevel4("missleX" + (random(3) + 1),_root.randRange(25,30));
  70.       var _loc3_ = 0;
  71.       var _loc5_ = random(3);
  72.       var _loc4_ = ["grey","red","grey2"];
  73.       while(_loc3_ < _loc5_)
  74.       {
  75.          _root.createShrapnel([this.x + this.clip._width / 2,this.y + this.clip._height / 2,_loc4_[random(2)]]);
  76.          _loc3_ = _loc3_ + 1;
  77.       }
  78.       this.yank = true;
  79.    }
  80.    function bombed()
  81.    {
  82.       _root.createExploA([this.x + this.clip._width / 2,this.y + this.clip._height / 2,_root.randRange(60,80),_root.randRange(85,100),"Purple"]);
  83.       _root.audio.playLevel4("missleX" + (random(3) + 1),_root.randRange(25,30));
  84.       var _loc3_ = 0;
  85.       var _loc5_ = random(3);
  86.       var _loc4_ = ["grey","red","grey2"];
  87.       while(_loc3_ < _loc5_)
  88.       {
  89.          _root.createShrapnel([this.x + this.clip._width / 2,this.y + this.clip._height / 2,_loc4_[random(2)]]);
  90.          _loc3_ = _loc3_ + 1;
  91.       }
  92.       this.yank = true;
  93.    }
  94.    function main()
  95.    {
  96.       this.ac = this.ac + 1;
  97.       if(this.ac == this.ep)
  98.       {
  99.          var _loc8_ = _root.getAngleRad(this.x,this.y);
  100.          this.xMovT = this.speed * Math.round(Math.cos(_loc8_));
  101.          this.yMovT = this.speed * Math.round(Math.sin(_loc8_));
  102.          if(this.xMovT < -1)
  103.          {
  104.             var _loc9_ = "L";
  105.          }
  106.          else if(this.xMovT > 1)
  107.          {
  108.             _loc9_ = "R";
  109.          }
  110.          else
  111.          {
  112.             _loc9_ = "";
  113.          }
  114.          if(this.yMovT < -1)
  115.          {
  116.             var _loc10_ = "U";
  117.          }
  118.          else if(this.yMovT > 1)
  119.          {
  120.             _loc10_ = "D";
  121.          }
  122.          else
  123.          {
  124.             _loc10_ = "";
  125.          }
  126.          this.clip.gotoAndStop("fly" + _loc9_ + _loc10_);
  127.          this.ac = 0;
  128.          this.ep = _root.randRange(10,30);
  129.       }
  130.       if(this.clip.hitTest(_root[_root.char + "Clip"]))
  131.       {
  132.          _root[_root.char].hit(this.xMov,this.yMov,100,this.power);
  133.          _root.createExploA([this.x + this.clip._width / 2,this.y + this.clip._height / 2,_root.randRange(60,80),_root.randRange(85,100)]);
  134.          _root.audio.playLevel4("missleX" + (random(3) + 1),_root.randRange(25,30));
  135.          var _loc3_ = 0;
  136.          var _loc6_ = random(3);
  137.          var _loc5_ = ["grey","red","grey2"];
  138.          while(_loc3_ < _loc6_)
  139.          {
  140.             _root.createShrapnel([this.x + this.clip._width / 2,this.y + this.clip._height / 2,_loc5_[random(2)]]);
  141.             _loc3_ = _loc3_ + 1;
  142.          }
  143.          this.yank = true;
  144.       }
  145.       _loc3_ = 0;
  146.       _loc6_ = _root.broShots.length;
  147.       while(_loc3_ < _loc6_)
  148.       {
  149.          var _loc7_ = _root.broShots[_loc3_] + "Clip";
  150.          if(this.clip.hitTest(_root[_loc7_]))
  151.          {
  152.             _root[_root.char].fc = _root[_root.char].fireFreq - _root.rapidVar;
  153.             var _loc4_ = _root.broShots[_loc3_];
  154.             _root[_loc4_].exploX = this.x + this.clip._width / 2;
  155.             _root[_loc4_].exploY = this.y + this.clip._height / 2;
  156.             _root[_loc4_].hit(2);
  157.             _root.createExploA([this.x + this.clip._width / 2,this.y + this.clip._height / 2,_root.randRange(60,80),_root.randRange(85,100)]);
  158.             _root.audio.playLevel4("missleX" + (random(3) + 1),_root.randRange(25,30));
  159.             _loc3_ = 0;
  160.             _loc6_ = random(3);
  161.             _loc5_ = ["grey","red","grey2"];
  162.             while(_loc3_ < _loc6_)
  163.             {
  164.                _root.createShrapnel([this.x + this.clip._width / 2,this.y + this.clip._height / 2,_loc5_[random(2)]]);
  165.                _loc3_ = _loc3_ + 1;
  166.             }
  167.             this.yank = true;
  168.          }
  169.          _loc3_ = _loc3_ + 1;
  170.       }
  171.       if(this.x > 1050 || this.x < -50 || this.y > 650 || this.y < -50)
  172.       {
  173.          this.yank = true;
  174.       }
  175.       if(this.xMovT < this.xMov)
  176.       {
  177.          this.xMov -= 0.5;
  178.       }
  179.       else if(this.xMovT > this.xMov)
  180.       {
  181.          this.xMov += 0.5;
  182.       }
  183.       else
  184.       {
  185.          this.xMov = this.xMovT;
  186.       }
  187.       if(this.yMovT < this.yMov)
  188.       {
  189.          this.yMov -= 0.5;
  190.       }
  191.       else if(this.yMovT > this.yMov)
  192.       {
  193.          this.yMov += 0.5;
  194.       }
  195.       else
  196.       {
  197.          this.yMov = this.yMovT;
  198.       }
  199.       this.x += this.xMov;
  200.       this.y += this.yMov;
  201.       if(this.yank)
  202.       {
  203.          this.yank = false;
  204.          _root.removeEnemyShot("droidCMissle" + this.id);
  205.       }
  206.       this.clip._x = this.x;
  207.       this.clip._y = this.y;
  208.    }
  209. }
  210.